import { IHttpPostData } from '@/typings';
import axios from '../lib/http';

//封装请求函数
function getQueries<T>(options: IHttpPostData): Promise<T> {
  const { subject, model } = options;

  //axios.post<T,T>固定写法
  return axios
    .post<T, T>('/api/query', {
      subject,
      model
    })
    .then((data: T) => {
      return data;
    })
    .catch((err) => {
      throw new Error('Request failed' + err);
    });
}

export { getQueries };
